import Vue from "vue";
import App from "./App";
import store from "./store";
import validate from "@/utils/validate.js";
import configAll from "@/config/configAll";
import toolUtils from "@/utils/toolUtils.js";
// console.log(__wxConfig.envVersion, "===这里是微信得环境============");
// 挂载到全局
import $p from "@/utils/public.js";
Vue.prototype.$p = $p;

Vue.prototype.$validate = validate;
Vue.config.productionTip = false;

App.mpType = "app";

import uView from "@/uni_modules/uview-ui";
Vue.use(uView);

import share from "@/utils/share.js";
Vue.mixin(share);
import Without from "@/components/without.vue";
Vue.component("without", Without);

import bottomAction from "@/components/bottomAction.vue";
Vue.component("bottomAction", bottomAction);

import bottomTabBar from "@/components/bottom-tab-bar.vue";
Vue.component("bottom-tab-bar", bottomTabBar);
import bottomTabBarCom from "@/components/bottom-tab-bar-com.vue";
Vue.component("bottom-tab-bar-com", bottomTabBarCom);

Vue.prototype.$store = store;
import { formatTime, parseTime } from "@/utils/index.js";
Vue.prototype.toolUtils = toolUtils;

Vue.prototype.pageConfig = {
  GET_MORE: 2,
  REFRESH: 1,
};

Vue.filter("ossListFix", function (value) {
  return value + configAll.image.ossListFix;
});

Vue.filter("ossGoodsList", function (value) {
  return value; //+ configAll.image.ossGoodsList;
});

Vue.filter("ossGoodsListFilter", function (value) {
  if (!value) return "";
  return value.split("?")[0]; //+ configAll.image.ossGoodsList;
});

Vue.filter("ossGoodsDetail", function (value) {
  return value; //+ configAll.image.ossGoodsDetail;
});

Vue.filter("price", function (value) {
  console.log(value, typeof value);
  if (typeof value == "number" && NaN != value) {
    return (value / 1.0).toFixed(2);
  }

  if (value == "" || (!value && value !== 0 && value !== "0") || NaN == value) {
    return "";
  }

  return (value / 1.0).toFixed(2);
});

Vue.filter("formatDate", function (time) {
  return parseTime(time, "{y}-{m}-{d}");
});

Vue.filter("formatTime", function (time) {
  return parseTime(time);
});

Vue.mixin({
  data() {
    return {
      statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
      //#ifdef MP-WEIXIN
      caniUseUserProfile: uni.getUserProfile ? true : false,
      //#endif
    };
  },
  methods: {
    goLogin() {
      uni.navigateTo({
        url: "/pages/login/login",
      });
    },
  },
});

const app = new Vue({
  ...App,
});
app.$mount();
